import { RouteRecordRaw } from 'vue-router'
import allUserRoute from './modules'
import Layout from '@/Layout/index.vue'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 

 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题

 * meta : {
    noKeep: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
  }
 */

const asyncRoute: RouteRecordRaw = {
  path: '/',
  name: 'Home',
  redirect: '/',
  component: Layout,
  children: [
    {
      path: '',
      name: 'Index',
      component: () => import('@/views/Home/index.vue'),
      meta: {
        icon: 'House',
        title: 'home.name'
      }
    },
    {
      path: '/personal',
      name: 'Personal',
      component: () => import('@/views/Personal/index.vue'),
      meta: {
        hidden: true,
        title: 'router.personal_center.index'
      }
    },
    ...allUserRoute
  ]
}
export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login/index.vue')
  },
  asyncRoute,
  {
    path: '/404',
    name: '404',
    component: () => import('@/Error/404')
  },
  {
    path: '/:pathMatch(.*)',
    redirect: '/404'
  }
]
